/**
 * 
 */
package net.phoenix.repository.observation;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.observation.Event;

/**
 * @author lixf
 *
 */
public class PropertyEvent implements Event {
	private Property property;
	private int type;
	private long date;
	private Map<String, Object> info;
	public static final String KEY_PROPERTY = "property";

	public PropertyEvent(Property property, int type) {
		this.property = property;
		this.type = type;
		this.date = Calendar.getInstance().getTimeInMillis();
		this.info = new HashMap<String, Object>();
		this.info.put(KEY_PROPERTY, property);
	}
	
	public Property getProperty(){
		return this.property;
		
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.jcr.observation.Event#getType()
	 */
	@Override
	public int getType() {
		return type;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.jcr.observation.Event#getPath()
	 */
	@Override
	public String getPath() throws RepositoryException {
		return property.getPath();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.jcr.observation.Event#getUserID()
	 */
	@Override
	public String getUserID() {
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.jcr.observation.Event#getIdentifier()
	 */
	@Override
	public String getIdentifier() throws RepositoryException {
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.jcr.observation.Event#getInfo()
	 */
	@Override
	public Map getInfo() throws RepositoryException {
		return this.info;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.jcr.observation.Event#getUserData()
	 */
	@Override
	public String getUserData() throws RepositoryException {
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.jcr.observation.Event#getDate()
	 */
	@Override
	public long getDate() throws RepositoryException {
		return this.date;
	}

}
